﻿using Microsoft.VisualStudio.TestTools.UITest.Common;
using System.Diagnostics;

namespace AXExtension.Filters
{
	/// <summary>
	/// A debugging filter that traces every action
	/// that is passed through it.
	/// </summary>
	class TracerFilter : Filter
	{

		public override void Run(IUITestActionStack stack)
		{
			UITestAction action = stack.Peek();
			WriteLine("Action {");
			WriteLine("ActionName: " + action.ActionName);
			WriteLine("UI Name: " + action.UIElement.Name);
			WriteLine("UI ControlType: " + action.UIElement.ControlTypeName);
			WriteLine("UI TechnologyName: " + action.UIElement.TechnologyName);
			WriteLine("UI Value: " + action.UIElement.Value);
			WriteLine("UI ClassName: " + action.UIElement.ClassName);
			WriteLine("}");
		}

		private void WriteLine(string str)
		{
			Trace.WriteLine(str + "<br/>");
		}
	}
}
